package Six;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayList<Person> personList=new ArrayList<Person>();
		ArrayList<Person> stuList=new ArrayList<Person>();
		ArrayList<Person> empList=new ArrayList<Person>();
		Scanner scan=new Scanner(System.in);
		while(scan.hasNextLine()){
			String s=scan.next();
			if(s.equals("s")){
				personList.add(new Student(scan.next(),scan.nextInt(),scan.nextBoolean(),scan.next(),scan.next()));
			}else if(s.equals("e")){
				personList.add(new Employee(scan.next(),scan.nextInt(),scan.nextBoolean(),scan.nextDouble(), new Company(scan.next())));

			}else{
				break;
			}	
		}
		Collections.sort(personList);
		for (int i = 0; i <personList.size() ; i++) {
			System.out.println(personList.get(i));
		}
		Collections.sort(personList);
		if(scan.next().equals("exit")){
			scan.close();
			return;
		}
		for (int i = 0; i < personList.size(); i++) {
			
			if(personList.get(i) instanceof Student){
				if(!stuList.contains((Student)personList.get(i))){
					stuList.add(personList.get(i));
				}
			}
			else{
				if(!empList.contains((Employee)personList.get(i))){
					empList.add(personList.get(i));
				}
			}
		}
		System.out.println("stuList");
		for(Person a:stuList){
			System.out.println(a);
		}
		System.out.println("empList");

		for(Person a:empList){
			System.out.println(a);
		}
		scan.close();

	}
}
